
function validateProbabilities(probabilities) {
  const sum = probabilities.reduce((a, b) => a + b, 0);
  return probabilities.every(p => p >= 0 && p <= 1) && Math.abs(sum - 1) < 1e-10;
}

function calculateEntropy(probabilities) {
  const entropy = probabilities.map(p => p * Math.log2(p)).reduce((a, b) => a - b, 0);
  return entropy
}


module.exports = { validateProbabilities, calculateEntropy };